import {Component, OnInit} from '@angular/core';
import {MatDialog} from '@angular/material/dialog';
import {TextdialogComponent} from '../text-dialog/text-dialog.component';

@Component({
  selector: 'app-electron',
  templateUrl: './electron.component.html',
  styleUrls: ['./electron.component.less']
})
export class ElectronComponent implements OnInit {

  items = [{
    name: '可以调用本地方法',
    success: true
  }, {
    name: '可以调用本地方法,并可以接收回调(Promise)',
    success: true
  }, {
    name: '可以调用本地方法,同步的方式',
    success: true
  }, {
    name: '桌面通知',
    success: true
  }, {
    name: '将http server 加入到工程中',
    success: true
  }]

  constructor(private  dialog: MatDialog) {
  }

  ngOnInit(): void {
  }

  fullScreen() {
    window.ElectronApi.ScreenApi.fullScreen()
  }

  exitFullScreen() {
    window.ElectronApi.ScreenApi.exitFullScreen()
  }

  readFile() {
    const value = window.ElectronApi.FileApi.readFile();
    this.dialog.open(TextdialogComponent, {
      data: {text: value}
    });
  }

  sendPost() {
    window.ElectronApi.httpTools.post('http://localhost:8087', '{}', function () {
      console.log(arguments)
    });
  }

  sendPostInMain() {
    window.ElectronApi.httpTools.postInMain('http://localhost:8087',{}, function () {
      // nothing
    });
  }


}
